layout.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { Viewport } from "next";
  2. import { NextIntlClientProvider } from "next-intl";
  3. import { getMessages } from "next-intl/server";
  4. import { Inter as FontSans } from "next/font/google";
  5. import { ReactNode } from "react";
  6. import "../globals.scss";
  7. import clsx from "clsx";
  8. import { Providers } from "./providers";
  9. // 加载字体
  10. const fontSans = FontSans({
  11. subsets: ["latin"],
  12. variable: "--font-sans",
  13. });
  14. export const viewport: Viewport = {};
  15. export const metadata = {
  16. keywords: ["Next.js"],
  17. description: "Next.js",
  18. appleWebApp: {
  19. statusBarStyle: "black",
  20. },
  21. formatDetection: {
  22. email: false,
  23. address: false,
  24. telephone: false,
  25. },
  26. other: {
  27. viewport: [
  28. "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover",
  29. ],
  30. },
  31. };
  32. export default async function LocaleLayout({
  33. children,
  34. params: { locale },
  35. }: {
  36. children: ReactNode;
  37. params: { locale: string };
  38. }) {
  39. const messages = await getMessages();
  40. return (
  41. <html lang={locale} suppressHydrationWarning>
  42. <body className={clsx("font-sans", fontSans.variable)}>
  43. <NextIntlClientProvider messages={messages}>
  44. <Providers themeProps={{ attribute: "class" }}>{children}</Providers>
  45. </NextIntlClientProvider>
  46. </body>
  47. </html>
  48. );
  49. }